package com.lcxw.hxzbapi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lcxw.hxzbapi.dao.mapper.JubaoMapper;
import com.lcxw.hxzbapi.entity.pojo.Jubao;
import com.lcxw.hxzbcommon.common.StringUtil;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class JubaoService {

    @Resource
    JubaoMapper jubaoMapper;

    public int insert(Jubao jubao) {
        return jubaoMapper.insert(jubao);
    }

    public int updateById(Jubao jubao) {
        return jubaoMapper.updateById(jubao);
    }

    public Jubao selectById(int id) {
        return jubaoMapper.selectById(id);
    }

    public IPage<Jubao> getList(String status, int pageNum, int pageSize) {
        IPage<Jubao> page = new Page<>(pageNum, pageSize);
        QueryWrapper<Jubao> w = new QueryWrapper<>();
        w.eq(!StringUtil.isEmpty(status), "status", status);
        return jubaoMapper.selectPage(page, w);
    }
}
